package com.blog.cloud.comm.webutils;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.blog.conf.MyConstants;

public class CommMethod {
	
	
	
	public static String getTbaleName(String className){
		
		String tabPreFix = MyConstants.TBALE_PREFIX;
		int length = className.length();
		for (int i = 0; i < length; i++) {
			char chr = className.charAt(i);
			if(i==0){
				tabPreFix += String.valueOf(chr).toLowerCase();
				continue;
			}
			if(Character.isUpperCase(chr)){  
				tabPreFix += "_"+  String.valueOf(chr).toLowerCase();
            }else{  
                tabPreFix += String.valueOf(chr);
            } 
		}
		return tabPreFix;
	}
	
	
	
	public static Map<String , Object> getMap(){
		return new HashMap<String , Object>();

	}
	
	

	public static void main(String[] args) {
		
		
		String tbaleName = getTbaleName("BlogType");
		System.out.println(tbaleName);
	}
	
	
	
	
	public static String formatPath(String path){
		
		path = path.replace("\\", "/");
		path = path.replace("\\\\", "//");
		
		return path;
	}

	
	/**  
	* @Title: getFieDir  
	* @Description: 获取文件路径   如：2017/10/10 
	* @param @param rootPath
	* @param @return
	* @return String
	* @author lxliufei
	* @date 下午5:48:49
	* @throws  
	*/  
	    
	public static String getFieDir(String rootPath) {
		String fileDir = rootPath;
		String currDate = DateUtils.getCurrDate();
		
		
		// 年
		String currYear = currDate.substring(0, 4);
		String fileDir_currYear = fileDir+File.separator+currYear;
		File fileDirP_1 = new File(fileDir_currYear);
		if(!fileDirP_1.exists()){
			fileDirP_1.mkdir();
		}
		//月
		String currMonth = currDate.substring(4, 6);
		String fileDir_currYear_currMonth = fileDir_currYear+File.separator+currMonth;
		File fileDirP_2 = new File(fileDir_currYear_currMonth);
		if(!fileDirP_2.exists()){
			fileDirP_2.mkdir();
		}
		// 日
		String currDay = currDate.substring(6, 8);
		String fileDir_currYear_currMonth_currDay = fileDir_currYear_currMonth+File.separator+currDay;
		File fileDirP_3 = new File(fileDir_currYear_currMonth_currDay);
		if(!fileDirP_3.exists()){
			fileDirP_3.mkdir();
		}
		
		fileDirP_1 = fileDirP_2 =fileDirP_3 = null;
		return fileDir_currYear_currMonth_currDay;
	}
}
